package StudentSystem;

class PersonalSystem extends InformationSystem {
    public PersonalSystem(){
        if(dkxz==1){
            System.out.println("<<<个人信息系统>>>");
            System.out.println("进入信息编辑系统");
            int wzl = 0, id, pd4 , tc = 1, pd2 ;//课程位置，需修改课程编号，判断是否修改  退出循环
            while (stpd == 0) {
                System.out.println("<<<学生信息编辑系统>>>");
                System.out.println("是否查看个人信息（查看输入1）");
                pd2 = sr.nextInt();
                if (pd2 == 1) {

                    System.out.println("学生个人信息");
                    System.out.println(student.get(wz).toString());

                }
                input1=0;
                System.out.println("是否修改学生个人信息（输入1进入）");
                input1=sr.nextInt();
                if(input1==1)

                {

                    System.out.println("学生名字");
                    student.get(wz).name = sr.nextLine();
                    System.out.println("学生性别");
                    student.get(wz).sex = sr.nextLine();
                    System.out.println("是否修改个人密码（输入1进入）");
                    if(sr.nextInt()==1){
                        sr.nextLine();
                        System.out.println("请输入新的个人密码：");
                        student.get(wz).password = sr.nextLine();
                    }
                }
                System.out.println("是否修改学生选课信息（输入1进入）");
                input1=sr.nextInt();
                while(tc==input1)
                {
                    System.out.println("请输入学生要修改或者查询的课程编号");
                    id = sr.nextInt();
                    int j,i;
                    j = 1;
                    while (j == 1) {
                        for (i = 0; i < student.get(wz).course_id.length; i++)//i是学生查询对应课程位置
                        {
                            if (student.get(wz).course_id[i] == id) {
                                wzl = i;//课程储存的位置
                                j = 0;
                                break;
                            }
                        }
                        if (j == 1) {
                            System.out.println("未查询到该课程！！\n请重新输入,要修改或者查询的课程编号");
                            id = sr.nextInt();
                        }
                    }
                    if (student.get(wz).course_id[wzl] == id) {
                        System.out.printf("    %-15s%-15s%-15s%s","课程号:" , "课程名字:" ,"课程时间:" ,"课程地点:\n");
                        System.out.printf("        %-15s%-15s%-15s%s",student.get(wz).course_id[wzl] , student.get(wz).course_name[wzl] ,student.get(wz).course_time[wzl] ,student.get(wz).course_sit[wzl]+"\n");

                        System.out.println("请输入学生要退/删课程(输入1改课，输入0退课,其他退出)");
                        pd4 = sr.nextInt();
                        if (pd4 == 1) {
                            System.out.println("请输入学生要选课程编号");
                            id = sr.nextInt();
                            for (i = 0; i < student.get(wz).course_time.length; i++) {
                                if (student.get(wz).course_id[i] == id) {
                                    wzl = i;
                                    break;
                                }
                            }
                            System.out.println("请输入学生所选课程编号");
                            student.get(wz).course_id[wzl] = sr.nextInt();
                            sr.nextLine();
                            System.out.println("请输入学生所选课程名字");
                            student.get(wz).course_name[wzl] = sr.nextLine();
                            System.out.println("请输入学生所选课程时间");
                            student.get(wz).course_time[wzl] = sr.nextLine();
                            System.out.println("请输入学生所选课程地点");
                            student.get(wz).course_sit[wzl] = sr.nextLine();

                        } else if (pd4 == 0) {
                            student.get(wz).course_id[wzl] = -1;
                            student.get(wz).course_name[wzl] = "无";
                            student.get(wz).course_time[wzl] = "无";
                            student.get(wz).course_sit[wzl] = "无";
                        }
                        System.out.println("是否完成课程信息修改(输入2退出)");
                        pd4 = sr.nextInt();
                        if (pd4 == 2) break;
                    } else {
                        System.out.println("输入学生要查询课程编号不存在或者错误！！\n若退出请输入输入1（重新输入请输入其他数）>>");
                        input1 = sr.nextInt();
                        if (input1 == 1) {
                            break;
                        }
                    }
                }
                System.out.println("退出信息查询系统请输入1（重新输入请输入其他数）>>");
                input1=sr.nextInt();
                if(input1==1)
                {
                    break;
                }
            }
            //教师信息查询
            while (stpd == 1) {
                System.out.println("<<<教师信息编辑系统>>>");

                System.out.println("是否查看个人信息（查看输入1）");
                pd2 = sr.nextInt();
                if (pd2 == 1) {

                    System.out.println("教师个人信息");
                    System.out.println(teacher.get(wz).toString());
                }
                System.out.println("是否修改个人信息（输入1为修改）");
                input1 = sr.nextInt();
                if (input1 == 1) {
                    System.out.println("请输入教师10位数编码>>");
                    teacher.get(wz).user_id = sr.nextInt();
                    sr.nextLine();
                    System.out.println("请输入教师名字>>");
                    teacher.get(wz).name = sr.nextLine();
                    System.out.println("请输入教师性别>>");
                    teacher.get(wz).sex = sr.nextLine();
                    System.out.println("是否修改个人密码（输入1进入）");
                    if (sr.nextInt() == 1) {
                        sr.nextLine();
                        System.out.println("请输入新的个人密码：");
                        student.get(wz).password = sr.nextLine();
                    }

                    System.out.printf("%5s", "    修改完成");
                    System.out.println("教师个人信息");
                    System.out.println("    教师名字：" + teacher.get(wz).name);
                    System.out.println("    教师性别：" + teacher.get(wz).sex);


                }
                System.out.println("退出信息查询系统请输入1（重新输入,请输入其他数）>>");
                input1 = sr.nextInt();
                if (input1 == 1) {
                    break;
                }

            }
        }
    }
}
